<template>
  <div>
    <div class="info-title-box">
      <div class="tip"></div>
      <div class="operation" @click="changeIsShow">
        <div class="info-text">{{ title }}</div>
        <div class="add-icon" v-if="isAdd">
          <router-link :to="`Information/${whereIs}/${cnta}`">
            <img src="./../image/u256.png">
          </router-link>
        </div>
        <div class="icon" :class="[!isShow?'rotate':'rotate-go']">
          <img src="./../image/u50.png" alt="">
        </div>
      </div>
    </div>
    <transition name="fade" mode="out-in">
      <div v-show="isShow">
        <slot/>
      </div>
    </transition>
  </div>
</template>

<script>
  export default {
    name: 'folding',
    props: {
      cnta:{
        type: String,
        default: ''
      },
      title: {
        type: String,
        default: ''
      },
      isAdd: {
        type: Boolean,
        default: false
      },
      whereIs: {
        type: String,
        default: ''
      }
    },
    data() {
      return {
        isShow: false
      }
    },
    methods:{
      changeIsShow(){
        this.isShow = !this.isShow;
        this.$emit('feedback',this.title)
      }
    }
  }
</script>

<style type="text/scss" lang="scss" scoped>
  .fade-enter-active, .fade-leave-active {
    transition: opacity .2s;
  }

  .fade-enter, .fade-leave-to /* .fade-leave-active below version 2.1.8 */
  {
    opacity: 0;
  }

  .rotate {
    transition: all .3s;
    transform: rotate(180deg);
  }

  .rotate-go {
    transition: all .3s;
    transform: rotate(0deg);
  }

  .info-title-box {
    display: flex;
    margin-bottom: 10px;
    padding: 3px;
    .tip {
      background-color: #1CAAFE;
      width: 6px;
      height: 18px;
    }
    .operation {
      border-bottom: 1px #ccc solid;
      margin-left: 15px;
      display: flex;
      width: 100%;
      .info-text {
        flex: 5;
        font-size:16px;
        text-align: left;
        margin-left: 5px;
        padding: 3px;
        color: black;
      }
      .add-icon {
        flex: 1;
        img {
          width: 18px;
        }
      }
      .icon {
        flex: 1;
        img {
          width: 18px;
        }
      }
    }
  }
</style>
